package service;

import Pojo.User;
import Pojo.UserExample;
import dao.UserMapper;
import java.io.PrintStream;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl
  implements UserService
{

  @Autowired
  private UserMapper userMapper;

  public List<User> userList()
    throws Exception
  {
    UserExample example = new UserExample();
    List list = this.userMapper.selectByExample(example);
    System.out.println("123" + list);
    return list;
  }

  public User login(User user) throws Exception
  {
    User user1 = this.userMapper.selectByUser(user);
    return user1;
  }

  public void regist(String userName, String passWord)
    throws Exception
  {
    User s = this.userMapper.selectUserByUsername(userName);
    if (s != null) {
      throw new Exception("该用户已注册！请勿重复注册");
    }

    String type = "zuke";
    this.userMapper.registUser(userName, passWord, type);
  }
}